package com.tianqingwl.gsystem.common.handler;

import com.tianqingwl.gsystem.common.vo.FileUploadResultVo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MaxUploadSizeExceededException;


@ControllerAdvice
public class GlobalExceptionHandler {

    @Value("${spring.servlet.multipart.max-file-size}")
    private String maxFileSize;

    @ResponseBody
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public Object maxUploadSizeExceededException(MaxUploadSizeExceededException exception){
        return FileUploadResultVo.fail("上传的文件太大，允许上传"+(maxFileSize)+"大小内的文件");
    }
}
